#include "Vertex.h"
#include <vtkActor.h>
#include <vtkCellArray.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkVertex.h>

Vertex::Vertex(QWidget *parent)
    : QMainWindow(parent)
{
	vtkWidget = new QVTKOpenGLNativeWidget(this);
	this->resize(600, 400);
	this->setCentralWidget(vtkWidget);

	vtkNew<vtkNamedColors> colors;

	vtkNew<vtkPoints> points;
	points->InsertNextPoint(0, 0, 0);

	vtkNew<vtkVertex> vertex;
	vertex->GetPointIds()->SetId(0, 0);

	vtkNew<vtkCellArray> vertices;
	vertices->InsertNextCell(vertex);

	vtkNew<vtkPolyData> polydata;
	polydata->SetPoints(points);
	polydata->SetVerts(vertices);

	// Setup actor and mapper
	vtkNew<vtkPolyDataMapper> mapper;
	mapper->SetInputData(polydata);

	vtkNew<vtkActor> actor;
	actor->SetMapper(mapper);
	actor->GetProperty()->SetPointSize(30);
	actor->GetProperty()->SetColor(colors->GetColor3d("PeachPuff").GetData());

	// Setup render window, renderer, and interactor
	vtkNew<vtkRenderer> renderer;
	vtkWidget->renderWindow()->AddRenderer(renderer);
	renderer->AddActor(actor);
	renderer->SetBackground(colors->GetColor3d("DarkGreen").GetData());
}
